package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.MarketCoupon;
import com.cskaoyan.bean.MarketCouponUser;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.CouponService;
import com.fasterxml.jackson.databind.ser.Serializers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/***
 * title AdminCouponController
 * @description <TODO description class purpose>
 * @author ZCZ
 * @version 1.0.0
 * @create 2022/9/9 13:26
 **/
@RestController
@RequestMapping("admin/coupon")
public class AdminCouponController {
    @Autowired
    CouponService couponService;

    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info,String name,Short type,Short status){
        CommonData<MarketCoupon> data = couponService.getAllInfo(info,name,type,status);
        return BaseRespVo.ok(data);
    }

    //goodsvalue是什么类型的数组
    @RequestMapping("create")
    public  BaseRespVo  create(@RequestBody MarketCoupon marketCoupon){
        MarketCoupon marketCoupon1 = couponService.create(marketCoupon);
        return BaseRespVo.ok(marketCoupon1);
    }
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketCoupon marketCoupon){
        couponService.delete(marketCoupon);
        return  BaseRespVo.ok3();
    }
    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketCoupon marketCoupon){
        MarketCoupon marketCoupon1 = couponService.update(marketCoupon);
        return BaseRespVo.ok(marketCoupon1);
    }

    @RequestMapping("read")
    public BaseRespVo update(int id){
        MarketCoupon marketCoupon = couponService.read(id);
        return BaseRespVo.ok(marketCoupon);
    }

    @RequestMapping("listuser")
    public BaseRespVo listuser(BasePageInfo info,int couponId, Integer userId,Short status){
        CommonData<MarketCouponUser> marketCouponUserCommonData = couponService.getMarketCouponUser(info,couponId,userId,status);
        return BaseRespVo.ok(marketCouponUserCommonData);
    }

}
